package com.jinbo.sxzq;

import android.util.Log;
/***********棋子虎********************/
public class Chess_Long extends Chess{

    Chess_Long(int type, int index, int[] location, int owner, GameControl gameControl) {
        /********初始化信息****************/
        super(index, location, owner, gameControl);
        this.type = type;
        this.name = ProjectConstants.ChessName.LONG;
        this.message = ProjectConstants.ChessMasage.LONG;
        this.type = ProjectConstants.ChessType.LONG;
        this.hp = 3;
        this.maxHp = 3;
        this.mp = 0;
        this.maxMp = 0;
        this.mobility = 1;
        this.maxmobility = 1;
        this.atk = 3;
    }

    public void Action(){
        mp++;
        float minlength = 100;//离自己最近的敌方棋子的距离
        int aimindex = -1;//目标棋子的索引位置
        if(this.mp >= this.maxMp){//触发技能
            Skill();
        }
        for(int i = 0 ; i < gameControl.chess_list.size() ; i++){//找到离自己最近的敌方棋子
            if(gameControl.chess_list.get(i).getOwner(this) != owner){
                Chess chess = gameControl.chess_list.get(i);
                float length = Math.max(chess.location[0]-location[0],chess.location[1]-location[1]);
                if(minlength > length){
                    minlength = length;
                    aimindex = i;
                }
            }
        }
        //重写技能龙：【龙息】无法移动，攻击距离自己最近的敌方棋子。
        if(aimindex != -1){
            Attack(gameControl.chess_list.get(aimindex));
            Log.e("Skill——龙" , "触发技能");
        }else{
            Log.e("Action","未选中目标棋子");
        }
    }

    public void Move(Chess chess){
        super.Move(chess);
    }

    public void Attack(Chess chess){
        super.Attack(chess);
    }

    public void RoundNext(){
        super.RoundNext();
    }

    public void Skill(){
        super.Skill();
    }

    public void Kill(Chess chess){
        super.Kill(chess);
    }
}
